package com.example.nettydemo.entity;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author WZW
 * @date 2020/5/9
 */
@Data
public class Group {
    private List<Player> players;
    private int betCount;
    private boolean win;

    public Group() {
        this.players = new ArrayList<>();
    }

    public int playerCount() {
        return this.players.size();
    }

    public int sumBet() {
        return this.players.stream().mapToInt(Player::getBet).sum();
    }

    /**
     * 是否包含指定的玩家
     *
     * @param guid 玩家guid
     * @return true:包含,false:不包含
     */
    public boolean containsPlayer(String guid) {
        for (Player player : players) {
            if (player.getGuid().equals(guid)) {
                return true;
            }
        }
        return false;
    }
}
